export default class DirectoryOperate {
	createNewDir(url, dirnam) {
		//url值可支持相对路径URL、本地路径URL
		return new Promise((resolver, reject) => {
			plus.io.resolveLocalFileSystemURL(url, function(entry) {
				entry.getDirectory(dirName, {
					create: true,
					exclusive: false
				}, function(dir) {
					resolver(true)
				}, function(error) {
					reject(error.message)
					uni.showToast({
						title: dirName + '目录创建失败:' + error.message,
						duration: 2000,
						icon: 'none'
					});
				});
			}, function(e) {
				reject(error.message)
				uni.showToast({
					title: '获取目录失败:' + e.message,
					duration: 2000,
					icon: 'none'
				});
			});
		});
	}
	
	/**
	 * 获取文件
	 * @param {Object} url
	 */
	getDirsys(url) {
		return new Promise((resolve, reject) => {
			
			plus.io.resolveLocalFileSystemURL(url, (entry) => {
				resolve(entry)
			}, (e) => {
				reject(e)
				console.log(e);
			});
		})
	}

}